import {
  Controller,
  Inject,
  Get,
  Query,
  Body,
  Post,
  Param,
  Del,
} from '@midwayjs/core';
import { ModelService } from '@service/jx3/model.service';
import { ListModelDTO } from '@dto/jx3/model.dto';
import { BusinessType, Log } from '@decorator/log.decorator';

@Controller('/jx3/model')
export class PostController {
  @Inject()
  ModelService: ModelService;

  // 获取列表
  @Get('/list')
  async list(@Query() queryParams: ListModelDTO) {
    return await this.ModelService.list(queryParams);
  }

  // 新增
  @Log({ title: '模型新增', businessType: BusinessType.ADD })
  @Post('/add')
  async create(@Body() Model: any) {
    return await this.ModelService.create(Model);
  }

  // 删除
  @Log({ title: '模型删除', businessType: BusinessType.REMOVE })
  @Del('/:ModelId')
  async delete(@Param('ModelId') ModelId: string) {
    return await this.ModelService.delete(ModelId);
  }

  // 修改
  @Log({ title: '模型修改', businessType: BusinessType.EDIT })
  @Post('/update')
  async update(@Body() Model: any) {
    return await this.ModelService.update(Model);
  }

  // 获取模型详情
  @Get('/:ModelId')
  async get(@Param('ModelId') ModelId: string) {
    return await this.ModelService.detail(ModelId);
  }
}
